<?php

class MKhoaLan extends CI_Model
{
	function danhsachkhoalan()
	{
		
				
		return $this->db->get('khoalan')->result();
	}
	
	function thongtinkhoalan($makl)
	{
		$this->db->where('makl', $makl);
		return $this->db->get('khoalan')->row();
	}
	
	function danhsachkhoalanmoinhat()
	{
		$this->db->order_by('makl', 'desc');
		return $this->db->get('khoalan', 4, 0)->result();
	}
	
	function xoakl($makl)
	{
		$this->db->where('makl', $makl);
		$this->db->delete('khoalan');
	}
	
	function themkl($tenkl, $magv, $ngaybatdau, $ngayketthuc, $gia, $mota, $hinh, $hienthi, $madm)
	{
		$this->db->set('tenkl', $tenkl);
		$this->db->set('magv', $magv);
		$this->db->set('ngaybatdau', $ngaybatdau);
		$this->db->set('ngayketthuc', $ngayketthuc);
		$this->db->set('gia', $gia);
		$this->db->set('mota', $mota);
		$this->db->set('hinh', $hinh);
		$this->db->set('hienthi', $hienthi);
		$this->db->set('madm', $madm);
		$this->db->insert('khoalan');
	}
	
	function capnhatkl($makl, $tenkl, $magv, $ngaybatdau, $ngayketthuc, $gia, $mota, $hienthi, $madm)
	{
		$this->db->where('makl', $makl);
		$this->db->set('tenkl', $tenkl);
		$this->db->set('magv', $magv);
		$this->db->set('ngaybatdau', $ngaybatdau);
		$this->db->set('ngayketthuc', $ngayketthuc);
		$this->db->set('gia', $gia);
		$this->db->set('mota', $mota);
		$this->db->set('hienthi', $hienthi);
		$this->db->set('madm', $madm);
		$this->db->update('khoalan');
	}
	
	function danhsachspAdmin()
	{
		return $this->db->get('khoalan')->result();
	}
	
}

?>